<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>

<?php
/** @var $this \Magento\Webapi\Block\Adminhtml\Integration\Edit\Tab\Webapi */
?>

<?php echo $this->getChildHtml(); ?>

<fieldset class="fieldset form-inline entry-edit">
    <legend class="legend">
        <span><?php echo __('Available APIs') ?></span>
    </legend><br />

    <div class="field">
        <label class="label" for="all_resources"><span><?php echo __('Resource Access') ?></span></label>

        <div class="control">
            <select id="all_resources" name="all_resources" onchange="jQuery('[data-role=tree-resources-container]').toggle()" class="select">
                <option value="0" <?php echo ($this->isEverythingAllowed()?'':'selected="selected"'); ?>><?php echo __('Custom') ?></option>
                <option value="1" <?php echo ($this->isEverythingAllowed()?'selected="selected"':''); ?>><?php echo __('All') ?></option>
            </select>
        </div>
    </div>

    <div class="field<?php if($this->isEverythingAllowed()):?> no-display<?php endif?>" data-role="tree-resources-container">
        <label class="label"><span><?php echo __('Resources') ?></span></label>

        <div class="control">
            <div class="tree x-tree" data-role="resource-tree" data-mage-init='<?php
            echo $this->escapeHtml($this->helper('Magento\Core\Helper\Data')->jsonEncode(array(
                'rolesTree' => array(
                    "treeInitData" => $this->getTree(),
                    "treeInitSelectedData" => $this->getSelectedResources(),
                )
            )));
            ?>'></div>
        </div>
    </div>
</fieldset>
